package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.hosp.bean.Result;
import com.atguigu.yygh.hosp.service.DepartmentService;
import com.atguigu.yygh.model.hosp.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/3/16 15:37
 */
@RestController
@RequestMapping("/api/hosp")
public class ApiDepartmentController {
    @Autowired
    private DepartmentService departmentService;
    //保存科室信息
    @PostMapping("/saveDepartment")
    public Result saveDepartment(HttpServletRequest request){
        departmentService.saveDepartment(request);
        return Result.ok();
    }

    //查询科室信息
    @PostMapping("/department/list")
    public Result list(HttpServletRequest request){
        Page<Department> page =departmentService.findDepartmentPage(request);

        return Result.ok(page);
    }
    //删除科室信息
    @PostMapping("/department/remove")
    public Result remove(HttpServletRequest request){
        departmentService.removeDepartment(request);
        return Result.ok();
    }
}
